package com.chaodriod.common.glide;

import android.content.Context;

import com.bumptech.glide.Registry;
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.module.AppGlideModule;

import java.io.InputStream;

import okhttp3.OkHttpClient;

/**
 * Created by CHEN on 2018/4/13.
 * 解决Glide 加载 HTTPS 图片的问题
 * Glide只能有1个AppGlideModule,并且值能在Application模块中
 */
//@GlideModule
public class OkHttpGlideModule extends AppGlideModule {

    public void registerComponents(Context context, Registry registry) {
        OkHttpClient client = UnsafeOkHttpClient.getUnsafeOkHttpClient();
        registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(client));
    }

}